/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部工具栏 */
.header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-bottom: 3px solid #3498db;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left h1 {
    font-size: 20px;
    font-weight: 600;
}

.version {
    background: #3498db;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.header-center {
    display: flex;
    gap: 10px;
}

.header-right .status {
    background: #27ae60;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* 主要内容区域 */
.main-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 区域样式 */
.section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
    overflow: hidden;
}

.section-header {
    background: linear-gradient(90deg, #f8f9fa, #e9ecef);
    padding: 16px 20px;
    border-bottom: 2px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.section-actions {
    display: flex;
    gap: 8px;
}

/* 表格样式 */
.table-container {
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: #34495e;
    color: white;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #dee2e6;
}

.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

.data-table tbody tr.selected {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.data-table input, .data-table select {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 12px;
}

.data-table input:focus, .data-table select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* 底部区域 */
.bottom-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* 信号预览 */
.preview-section {
    min-height: 300px;
}

.preview-content {
    padding: 20px;
}

.signal-preview {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    min-height: 250px;
    border: 2px dashed #dee2e6;
}

.preview-info {
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* 字节预览 */
.byte-layout {
    margin: 16px 0;
}

.byte-row {
    display: flex;
    align-items: center;
    margin: 8px 0;
    gap: 12px;
}

.byte-label {
    min-width: 80px;
    font-weight: 600;
    color: #34495e;
}

.bit-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    background: #dee2e6;
    border-radius: 4px;
    padding: 4px;
    min-width: 240px;
}

.bit-cell {
    background: white;
    padding: 8px 4px;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    font-weight: 600;
    border-radius: 2px;
}

.bit-cell.signal {
    background: #4CAF50;
    color: white;
}

.bit-cell.mask {
    background: #2196F3;
    color: white;
}

/* 计算区域 */
.calculation-area {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    margin-top: 16px;
}

.calc-row {
    display: flex;
    align-items: center;
    margin: 8px 0;
    gap: 8px;
    font-family: 'Courier New', monospace;
}

.calc-input {
    width: 120px;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

/* DBC预览 */
.dbc-section {
    min-height: 300px;
}

.dbc-content {
    max-height: 400px;
    overflow-y: auto;
}

.dbc-text {
    background: #2d3748;
    color: #e2e8f0;
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* 底部状态栏 */
.footer {
    background: #34495e;
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    border-top: 2px solid #2c3e50;
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .bottom-sections {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 10px;
        padding: 16px;
    }
    
    .header-center {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .main-content {
        padding: 10px;
    }
    
    .table-container {
        font-size: 11px;
    }
    
    .data-table th,
    .data-table td {
        padding: 6px 4px;
    }
}

/* 全屏模式 */
body.fullscreen {
    overflow: hidden;
}

body.fullscreen .main-content {
    height: calc(100vh - 120px);
}

/* 选择状态样式 */
.selected-message {
    background-color: #e3f2fd !important;
    border-left: 4px solid #2196f3 !important;
}

.selected-signal {
    background-color: #e8f5e8 !important;
    border-left: 4px solid #4caf50 !important;
}

/* 错误和警告样式 */
.error {
    color: #e74c3c;
    font-weight: 600;
}

.warning {
    color: #f39c12;
    font-weight: 600;
}

.success {
    color: #27ae60;
    font-weight: 600;
}

/* 工具提示 */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
} 